import type { StudentForm } from "@/types/student";
import request from "./request";
import type { DataList, RESPONSE } from "@/types/base";

enum API {
  ADD_STU = "/manage/student/add",
  GET_STU_BY_PAGE = "/manage/student/list",
  UPDATE_STU = "/manage/student/update",
  DEL_STU = "/manage/student/delete",
  FIND_STU = "/manage/student/find",
}

export const reqGetStu = (data: {
  page: number;
  size: number;
  searchMap: string;
}) =>
  request.post<null, RESPONSE<DataList<StudentForm>>>(
    API.GET_STU_BY_PAGE,
    data
  );

export const reqAddStu = (data: StudentForm) =>
  request.post<null, RESPONSE<StudentForm>>(API.ADD_STU, data);

export const reqFindStu = (_id: string) =>
  request.get(API.FIND_STU, { params: { _id } });

export const reqUpdateStu = (data: StudentForm) =>
  request.post<null, RESPONSE<StudentForm>>(API.UPDATE_STU, data);

export const reqDelStu = (studentId: string) =>
  request.post(API.DEL_STU, { studentId });
